#ifndef MINIMUSIC_H
#define MINIMUSIC_H

#include <QWidget>
#include<QMouseEvent>
#include<QGraphicsDropShadowEffect>
#include<QJsonArray>
#include <QJsonObject>
#include "volumetool.h"
#include <QDir>
#include <QFileDialog>
#include "musiclist.h"
#include "common.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MiniMusic; }
QT_END_NAMESPACE
#include "btform.h"
#include <QDebug>
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QPropertyAnimation>
#include "lrcpage.h"
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QMessageBox>
class MiniMusic : public QWidget
{
    Q_OBJECT

public:
    MiniMusic(QWidget *parent = nullptr);
    ~MiniMusic();
    void initPlayer();
    void initUI();
    void onUpdateLikeMusic(bool isLike, QString musicId);
    void onBtFormClick(int id);
    void connectSignalAndSlot();
    QJsonArray RandomPicture();
    void onPlayStateChanged();
    void onPlaybackModeChanged(QMediaPlaylist::PlaybackMode playbackMode);
    void onPlayAll(PageType pageType);
    void playAllOfCommonPage(Common* commonPage, int index);
    void onCurrentIndexChanged(int index);
    void setMusicSilence(bool isMuted);
    void setPlayerVolume(int vomume);
    void onDurationChanged(qint64 duration);
    void onPositionChanged(qint64 duration);
    void onMusicSliderChanged(float value);
    void onMetaDataAvailableChanged(bool available);
    void playMusicByIndex(Common* page, int index);
    void initMusicList();
    void initSQLite();
protected:
    void mousePressEvent(QMouseEvent *event)override;
    void mouseMoveEvent(QMouseEvent *event)override;
private slots:
    void on_volume_clicked();

    void on_addlocal_clicked();

    void on_play_clicked();

    void on_playUp_clicked();

    void on_playDown_clicked();

    void on_playMode_clicked();

    void on_lrcWord_clicked();

    void on_quit_clicked();

private:
    QPoint dragPosition;
    Ui::MiniMusic *ui;
    VolumeTool* volumeTool;
    MusicList musicList;
    QMediaPlayer* player;
    QMediaPlaylist* playList;
    Common* curPage;
    qint64 totalTime;
    int currentIndex;
    LrcPage* lrcPage;
    QPropertyAnimation* lrcAnimation;
    QSqlDatabase sqlite;
};
#endif // MINIMUSIC_H
